<template>
  <div class="home">
    <!-- Hero Section -->
    <section class="hero" id="home">
      <div class="hero-content">
        <h1>{{ t('heroTitle') }}</h1>
        <p>{{ t('heroSubtitle') }}</p>
        <a href="#products" class="cta-button" @click="scrollToProducts">
          {{ t('exploreProducts') }}
        </a>
      </div>
    </section>

    <!-- Products Section -->
    <section class="products" id="products">
      <div class="container">
        <h2 class="section-title">{{ t('featuredProducts') }}</h2>
        <div class="products-grid">
          <ProductCard
            v-for="product in products"
            :key="product.id"
            :product="product"
            @click="navigateToProduct(product.route)"
          />
        </div>
      </div>
    </section>

    <!-- AI Assistant Section -->
    <AIAssistant />

    <!-- Footer -->
    <Footer />
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from '../composables/useI18n'
import ProductCard from '../components/ProductCard.vue'
import AIAssistant from '../components/AIAssistant.vue'
import Footer from '../components/Footer.vue'

const router = useRouter()
const { t } = useI18n()

const products = computed(() => [
  {
    id: 1,
    icon: 'fas fa-home',
    title: t('smartHomeSystem'),
    description: t('smartHomeDesc'),
    price: '¥15,999',
    route: 'SmartHome'
  },
  {
    id: 2,
    icon: 'fas fa-industry',
    title: t('industrialAutomation'),
    description: t('industrialDesc'),
    price: '¥89,999',
    route: 'Industrial'
  },
  {
    id: 3,
    icon: 'fas fa-heartbeat',
    title: t('medicalElectronics'),
    description: t('medicalDesc'),
    price: '¥45,999',
    route: 'Medical'
  },
  {
    id: 4,
    icon: 'fas fa-shield-alt',
    title: t('securitySystem'),
    description: t('securityDesc'),
    price: '¥25,999',
    route: 'Security'
  }
])

const navigateToProduct = (routeName) => {
  router.push({ name: routeName })
}

const scrollToProducts = (e) => {
  e.preventDefault()
  document.getElementById('products').scrollIntoView({ behavior: 'smooth' })
}
</script>

<style scoped>
.hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
  padding: 0 1rem;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
  animation: float 20s ease-in-out infinite;
}

.hero-content {
  max-width: 800px;
  z-index: 2;
  position: relative;
  padding: 2rem 0;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  animation: slideInUp 1s ease-out;
}

@media (min-width: 768px) {
  .hero h1 {
    font-size: 3.5rem;
  }
}

.hero p {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  animation: slideInUp 1s ease-out 0.3s both;
  line-height: 1.6;
}

@media (min-width: 768px) {
  .hero p {
    font-size: 1.3rem;
  }
}

.cta-button {
  background: linear-gradient(45deg, #ff6b6b, #ee5a24);
  color: white;
  padding: 1rem 2rem;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  animation: slideInUp 1s ease-out 0.6s both;
  text-decoration: none;
  display: inline-block;
}

@media (min-width: 768px) {
  .cta-button {
    font-size: 1.1rem;
  }
}

.cta-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(255, 107, 107, 0.3);
}

.products {
  padding: 3rem 0;
  background: #f8f9fa;
}

@media (min-width: 768px) {
  .products {
    padding: 5rem 0;
  }
}

.section-title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 2rem;
  color: #2c3e50;
}

@media (min-width: 768px) {
  .section-title {
    font-size: 2.5rem;
    margin-bottom: 3rem;
  }
}

.products-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 3rem;
  }
}

@media (min-width: 1024px) {
  .products-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
</style>
